using Framework;
using Framework.UI;
using Framework.Graphics;
using UnityEngine;
using UnityEngine.UI;


namespace Game {
    public sealed class FightPausePanel : UIPanel
    {
        private void Awake()
        {
            this.AddEvents();
        }

        private void OnDestroy()
        {
            this.DelEvents();
            GameEntry.Event.BroadCast(GlobalEventType.ResumeFight);
        }

        public void OnClickContinueBtn()
        {
            this.Close();
        }

        public void OnClickCharacterBtn()
        {
            GameEntry.UI.OpenUI(AssetUtility.GetUIPath("Character/CharacterPanel")).Coroutine();
        }

        public void OnClickExitBtn()
        {
            GameEntry.Scene.LoadScene("MainScene");
            this.Close();
        }

        private void OnEnable()
        {
            GameEntry.Graphics.SetRenderFeatureActive(ERenderFeature.BokenBlur, true);
        }
        
        private void OnDisable()
        {
            GameEntry.Graphics.SetRenderFeatureActive(ERenderFeature.BokenBlur, false);
        }

        private void AddEvents()
        {
            GameEntry.Input.AddKeyCodeListener(KeyCode.Escape, this.OnClickContinueBtn);
        }

        private void DelEvents()
        {
            GameEntry.Input.DelKeyCodeListener(KeyCode.Escape, this.OnClickContinueBtn);
        }
    }
}